#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTimer>
#include <QTcpServer>
#include <QTcpSocket>
#include <QThread>
#include "v4l2api.h"
#include "rfid.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

signals:
    void cardDetected(unsigned int cardId);

private slots:
    void onUpdateCameraUi();
    void onNewClientConnect();
    void onRecvDataSlot();
    void onCardDetected(unsigned int cardId);

private:
    Ui::Widget *ui;

    QTimer *m_timer;
    V4l2Api *v4l2;

    QTcpServer *m_tcpServer;
    QTcpSocket* tcpClient;
    QImage saveImg;
    QImage img;

    // RFID相关成员
    int m_rfidFd; // 串口文件描述符
    QThread *m_rfidThread;
    QTimer *m_rfidTimer;
};
#endif // WIDGET_H
